package com.mitaotao._1_语法._4_循环.单循环._03_最小整数n;

public class _03_1_最大整数n {
    //1+2+3+4+..+n < 8888n的最大值
    public static void main(String[] args) {
        //1+2+3+4+..+n < 8888时n的最大值
        int sum = 0;
        int n;
        for (n=1; ;n++){
            sum = sum+n;
            if (sum>8888){
                sum = sum - n;
                n= n-1;
                break;
            }
        }
        System.out.println("sum = "+sum);
        System.out.println("n的最大值为："+n);
    }
}
